

clear all
set more off
set maxvar 32767

*global afrobar="C:\Users\xisaka\ShareFile\Personal Folders\Afrobarometer"
global aiddata="C:\Users\xisaka\ShareFile\Personal Folders\AidData\replication data"
*global china_ethnic= "C:\Users\xisaka\Dropbox\Ias\MINA PAPERS\chinese aid and ethnic sentiments\stata"
*global temp="C:\Users\xisaka\ShareFile\Personal Folders\temp data"


*ADD YOUR DIRECTORY HERE e.g:

*global aiddata="C:\xxxxxxxxxxxxxxxxxxxx"




**************************USING THE DATASET FOCUSING ON ALL CHINESE FLOWS AND THE AFROBAR INCLUDING PRECISION CODES 1-3************************





use "$aiddata/chinese all projects_afro precision code 1 2 3 data_replication.dta", clear




*************************************************************************************************************************************************************
********************************************************FIGURES AND TABLES FROM THE PAPER********************************************************************
*************************************************************************************************************************************************************







*************************************************************Table 1: Chinese aid and ethnic identity
*******************************************************************************************************
	
*BENCHMARK ESTIMATION
reg ethnicidentity ongoing25 future25 age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, replace dec(3) ctitle(25 km cutoff) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 
	
	
	
	
	
	
	


*Figure 1: Map of Chinese aid project sites and 25 km buffer zones around Afrobarometer survey clusters
*******************************************************************************************************

*not made in stata











***FIGURE 2: coefplot for ongoing-future when using different geographical cut-offs
***********************************************************************************

*10 km cutoff.
	gen helpvar10 = diffhelp10						
	label var helpvar10 "10 km cut-off"
reg ethnicidentity sum_ongoingfuture10 helpvar10 age age2 female urban cd* yd* if completed10==0 & restrictedestsample==1, cluster(cluster)
	estimates store ten

*25 km cut-off
	gen helpvar25 = diffhelp25						
	label var helpvar25 "25 km cut-off"
reg ethnicidentity sum_ongoingfuture25 helpvar25 age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster) 
	estimates store twentyfive
	
*50 km cutoff
	gen helpvar50= diffhelp50						
	label var helpvar50 "50 km cut-off"
reg ethnicidentity sum_ongoingfuture50 helpvar50 age age2 female urban cd* yd* if completed50==0 & restrictedestsample==1, cluster(cluster)
	estimates store fifty
	
*75 km cutoff
	gen helpvar75 = diffhelp75						
	label var helpvar75 "75 km cut-off"
reg ethnicidentity sum_ongoingfuture75 helpvar75 age age2 female urban cd* yd* if completed75==0 & restrictedestsample==1, cluster(cluster)
	estimates store seventyfive
	
coefplot  (ten) (twentyfive) (fifty) (seventyfive), nooffsets keep(helpvar*) xline(0)  xtitle(Difference b_ongoing-b_future)  graphregion(fcolor(white))  
		

	
	
	
	
	
	
	
*****************************FIGURE 3: coefplots for other sensitivity estimations
***********************************************************************************

*benchmark	
gen benchmarkvar = diffhelp25						
label var benchmarkvar "Benchmark sample"
reg ethnicidentity sum_ongoingfuture25 benchmarkvar age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster) 
	estimates store benchmarksample
	
*logit
gen logitvar = diffhelp25
label var logitvar "Logit"
logit ethnicidentity sum_ongoingfuture25 logitvar age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	margins,  dydx(logitvar) post
	estimates store logitest

/**using ordinal dependent.... leave this one out of the graph due to different scaling
reg ethid_ordinal sum_ongoingfuture25 diffhelp25 age age2 female urban		cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	estimates store ordinal*/
	
*including those with, but controlling for, completed projects nearby 
gen completedvar = diffhelp25
label var completedvar "Completed included"
reg ethnicidentity sum_ongoingfuture25 completedvar completedvar 			age age2 female urban cd* yd* if restrictedestsample==1, cl(cluster)
	estimates store completed

*alternative estimation sample (including some countries without obs connected to future)
gen extendedvar = diffhelp25
label var extendedvar "Extended sample"
reg ethnicidentity sum_ongoingfuture25 extendedvar age age2 female urban cd* yd* if completed25==0 & ethnicestsample2==1, cluster(cluster)
estimates store extended_sample

*geomatching. exlude those with no projects within 100 km 
gen geomatchvar = diffhelp25
label var geomatchvar "Geo-matched"
reg ethnicidentity sum_ongoingfuture25 geomatchvar	age age2 female urban cd* yd* if numberwithin100>0 & completed25==0 & restrictedestsample==1, cl(cluster)
	estimates store geomatch
	
*using only precision code 1 in the afrobarometer OPEN NEW DATASET

preserve
	use "$aiddata/chinese all projects_afro restricted to precision code 1 data_replication.dta", clear
	rename active25 		ongoing25
	rename inactive25 		future25
	rename suspended25 		completed25
	gen sum_ongoingfuture25 = ongoing25+future25 	
	gen diffhelp25 = ongoing25
	gen 	restrictedestsample	=cond(((country=="Benin" | country=="Botswana" | country=="Cape Verde" | country=="Kenya" | country=="Liberia" | country=="Madagascar" | country=="Malawi" | country=="Mali" |	country=="Namibia" | country=="Nigeria" | country=="Senegal")  					///
 & ethnicidentity!=.	 & presethnic!=. & ongoing25!=. & future25!=. & age!=.),1,0) 	
 gen precision1var = diffhelp25
 label var precision1var "Afrobarometer precision 1"
 reg ethnicidentity sum_ongoingfuture25 precision1var age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store afrobar_precision1
restore	
		
*focusing on only ODA-like flows OPEN NEW DATASET.
preserve
	use "$aiddata/chinese ODA_afro precision code 1 2 3 data_replication.dta", clear
	rename active25 		ongoing25
	rename inactive25 		future25
	rename suspended25 		completed25
	gen sum_ongoingfuture25 = ongoing25+future25 	
	gen diffhelp25 = ongoing25
	gen 	restrictedestsample	=cond(((country=="Benin" | country=="Botswana" | country=="Cape Verde" | country=="Kenya" | country=="Liberia" | country=="Madagascar" | country=="Malawi" | country=="Mali" |	country=="Namibia" | country=="Nigeria" | country=="Senegal")  					///
 & ethnicidentity!=.	 & presethnic!=. & ongoing25!=. & future25!=. & age!=.),1,0) 	
 gen ODAvar = diffhelp25
label var ODAvar "Only ODA"
  reg ethnicidentity sum_ongoingfuture25 ODAvar age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store onlyODA
restore	

*region fixed effects
gen regionFEvar = diffhelp25
label var regionFEvar "Region FEs"
reg ethnicidentity sum_ongoingfuture25 regionFEvar age age2 female urban rd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store regionFEs
	
*dropping round 6 
gen noround6var = diffhelp25
label var noround6var "Without round 6"
reg ethnicidentity sum_ongoingfuture25 noround6var age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1 & wave<6, cluster(cluster)
estimates store withoutround6

*excluding observations where the future project will start during the next year 
gen nonextyearvar = diffhelp25
label var nonextyearvar "Exclude next year"
reg ethnicidentity sum_ongoingfuture25 nonextyearvar age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1 & timeuntilstart!=1, cluster(cluster)
estimates store excludenextyear


*time restriction on future, within 5 years
gen futurewitin5var = diffhelp25
label var futurewitin5var "Future within 5"
reg ethnicidentity sum_ongoingfuture25within5 futurewitin5var age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store futurewithin5

*restricting the sample to survey rounds within the same presidency/party (ignore changes in presidency of they are within the same party) in each country
gen noturnovervar = diffhelp25
label var noturnovervar "No party turnover"
reg ethnicidentity sum_ongoingfuture25 noturnovervar age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1 & noturnover==1, cluster(cluster)
estimates store noturnover

*country*linear timetrend. 
gen ctimetrendvar = diffhelp25
label var ctimetrendvar "Country time trend"
reg ethnicidentity sum_ongoingfuture25 ctimetrendvar age age2 female urban cd*##c.timetrend if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store countrytimetrend
		
*country-year dummies
gen countryyearFEvar = diffhelp25
label var countryyearFEvar "Country-year FEs"
reg ethnicidentity sum_ongoingfuture25 countryyearFEvar age age2 female urban cd*##yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store country_yearFEs

*regionFEs * linear timetrend	
gen regiontimetrendvar = diffhelp25
label var regiontimetrendvar "Region time trend"
keep if restrictedestsample==1
tab region, gen (rdrestricted)
set emptycells drop				
reg ethnicidentity sum_ongoingfuture25 regiontimetrendvar age age2 female urban rdrestricted*##c.timetrend if completed25==0 & restrictedestsample==1, cluster(cluster)
	estimates store regiontimetrend

/*
NOTE: THIS ESTIMATION TAKES SEVERAL HOURS. IF YOU WANT TO, INSTEAD RUN THE ALTERNATIVE FIGURE 3 CODE BELOW, EXCLUDING THIS PARTICULAR COEFFICIENT
*wave*rd fixed effects
gen regionyearFEvar = diffhelp25
label var regionyearFEvar "Region-year FEs"
keep if restrictedestsample==1 & completed25==0
*tab region, gen (rdrestricted)
set emptycells drop				//otherwise exceed maxvar 
reg ethnicidentity sum_ongoingfuture25 regionyearFEvar age age2 female urban rdrestricted*##wd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	estimates store regionwaveFE
*/


*FIGURE 3: coefplot sensitivity estimations. (INCLUDING THE ESTIMATION ABOVE THAT TAKES A LOT OF TIME)
coefplot  (benchmarksample)  (logitest, citype(logit))  (completed)   (extended_sample)   (afrobar_precision1)  (onlyODA) (regionFEs) (geomatch)  (withoutround6)  (excludenextyear) (futurewithin5)  (noturnover) (countrytimetrend) (country_yearFEs) (regiontimetrend) (regionwaveFE),  nooffsets   keep(benchmarkvar logitvar completedvar extendedvar precision1var ODAvar regionFEvar geomatchvar noround6var nonextyearvar futurewitin5var noturnovervar ctimetrendvar countryyearFEvar regiontimetrendvar regionyearFEvar) coeflabels(precision1var = "Afrobarometer precision 1" ODAvar = "Only ODA") xline(0)  xtitle(Difference b_ongoing-b_future)  graphregion(fcolor(white))   


*ALTERNATIVE FIGURE 3 WITHOUT THE REGION-WAVE FE (ESTIMATION TAKES SEVERAL HOURS)
coefplot  (benchmarksample)  (logitest, citype(logit))  (completed)   (extended_sample)   (afrobar_precision1)  (onlyODA) (regionFEs) (geomatch)  (withoutround6)  (excludenextyear) (futurewithin5)  (noturnover) (countrytimetrend) (country_yearFEs) (regiontimetrend) ,  nooffsets   keep(benchmarkvar logitvar completedvar extendedvar precision1var ODAvar regionFEvar geomatchvar noround6var nonextyearvar futurewitin5var noturnovervar ctimetrendvar countryyearFEvar regiontimetrendvar regionyearFEvar) coeflabels(precision1var = "Afrobarometer precision 1" ODAvar = "Only ODA") xline(0)  xtitle(Difference b_ongoing-b_future)  graphregion(fcolor(white))  
	
	
	
	
	
	
	
	
	
	
*********************************************************************************************************	
***************************************************APPENDIX FIGURES AND TABLES***************************
*********************************************************************************************************
	
	
	
	
	
*******************************Figure A1: Country share identifying in ethnic rather than national terms
*********************************************************************************************************
	
	preserve
		keep if restrictedestsample==1
		collapse ethnicidentity [pw= withinwt], by(country)
		graph bar ethnicidentity, over(country, sort(1) axis(noline)) blabel(group, position(outside) orientation(vertical)size(medium)) ///
		yline(0, lcolor(black)) aspectratio(0.4) graphregion(margin(zero) fcolor(white)) plotregion(margin(zero)) xsize(6)ysize(2.5)
	restore


	
	
	
	
	
	
***************************************************Figure A2: Timeline to illustrate estimation strategy
*********************************************************************************************************
	
*not created in stata	
	
	
	
	
	
	
	
	
	
	
	
	
****************************FIGURE A3: Estimated effects when using different time restrictions on ongoing and future	
***********************************************************************************************************************

*time restriction on future, within 5 years
*focusing on future projects starting within 5 years of the interview date	
gen helpfuture5 = diffhelp25
label var helpfuture5 "Future within 5"
reg ethnicidentity sum_ongoingfuture25within5 helpfuture5  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store futurewithin5

*focusing on future projects starting within 4 years of the interview date		
gen helpfuture4 = diffhelp25
label var helpfuture4 "Future within 4"
reg ethnicidentity sum_ongoingfuture25within4 helpfuture4  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store futurewithin4

*focusing on future projects starting within 3 years of the interview date	
gen helpfuture3 = diffhelp25
label var helpfuture3 "Future within 3"
reg ethnicidentity sum_ongoingfuture25within3 helpfuture3  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store futurewithin3
	
*focusing on future projects starting within 2 years of the interview date		
gen helpfuture2 = diffhelp25
label var helpfuture2 "Future within 2"
reg ethnicidentity sum_ongoingfuture25within2 helpfuture2  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store futurewithin2


*time restriction on ongoing, within 5 years
*focusing on future projects starting within 5 years of the interview date	
gen helpongoing5 = diffhelp25within5
label var helpongoing5 "Ongoing within 5"
reg ethnicidentity sum_ongoingwithin5future25 helpongoing5  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store ongoingwithin5

*time restriction on ongoing, within 4 years of the interview date		
gen helpongoing4 = diffhelp25within4
label var helpongoing4 "Ongoing within 4"
reg ethnicidentity sum_ongoingwithin4future25 helpongoing4  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store ongoingwithin4

*time restriction on ongoing, within 3 years of the interview date	 	
gen helpongoing3 = diffhelp25within3
label var helpongoing3 "Ongoing within 3"
reg ethnicidentity sum_ongoingwithin3future25 helpongoing3  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store ongoingwithin3
	
*time restriction on ongoing, within 2 years of the interview date		
gen helpongoing2 = diffhelp25within2
label var helpongoing2 "Ongoing within 2"
reg ethnicidentity sum_ongoingwithin2future25 helpongoing2  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store ongoingwithin2

*time restriction on both, within 5 years
*focusing on future projects starting within 5 years of the interview date	.
gen helpboth5 = diffhelp25within5
label var helpboth5 "Both within 5"
reg ethnicidentity sum_bothwithin5 helpboth5  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store bothwithin5

*time restriction on both, within 4 years of the interview date	
gen helpboth4 = diffhelp25within4
label var helpboth4 "Both within 4"	
reg ethnicidentity sum_bothwithin4 helpboth4  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store bothwithin4

*time restriction on both, within 3 years of the interview date	 	
gen helpboth3 = diffhelp25within3
label var helpboth3 "Both within 3"
reg ethnicidentity sum_bothwithin3 helpboth3  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store bothwithin3
	
*time restriction on both, within 2 years of the interview date		
gen helpboth2 = diffhelp25within2
label var helpboth2 "Both within 2"
reg ethnicidentity sum_bothwithin2 helpboth2  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
estimates store bothwithin2


*FIGURE A3
coefplot 	(futurewithin5)  (futurewithin4) (futurewithin3)  (futurewithin2)  (ongoingwithin5)  (ongoingwithin4) (ongoingwithin3)  (ongoingwithin2)  (bothwithin5)  (bothwithin4) (bothwithin3)  (bothwithin2), nooffsets   keep(help*) xline(0) xtitle(Difference b_ongoing-b_future)  graphregion(fcolor(white))   









*************Figure A4: World Bank aid and ethnic identity: different geographical cut-offs	

************Figure A5: World Bank aid and ethnic identity: sensitivity analysis			

*see estimations using the world bank dataset further down









******************************************************Table A1: Summary statistics
***********************************************************************************

sum ethnicidentity ethid_ordinal ongoing25 future25 completed25 ongoing10 future10 completed10 ongoing50 future50 completed50 ongoing75 future75 completed75  presethnic  preseth_future25 preseth_ongoing25 age female urban if restrictedestsample==1








*****************************Table A2: Variable descriptions

*not created in stata













*********Table A3: Chinese aid and ethnic identity: Different geographical cut-offs
***********************************************************************************

*10 km cutoff....  diff pos but not quite sign
reg ethnicidentity ongoing10 future10 age age2 female urban cd* yd* if completed10==0 & restrictedestsample==1, cluster(cluster)
	test ongoing10-future10=0	
	estadd scalar difference = _b[ongoing10]-_b[future10]
	outreg2 using C:/Data/TEST.doc, replace dec(3) ctitle(10 km cutoff) keep(ongoing10 future10) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing10-future10=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 
	
*25 km cutoff. BENCHMARK
reg ethnicidentity ongoing25 future25 age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(25 km cutoff) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 
	
*50 km cutoff
reg ethnicidentity ongoing50 future50 age age2 female urban cd* yd* if completed50==0 & restrictedestsample==1, cluster(cluster)
	test ongoing50-future50=0	
	estadd scalar difference = _b[ongoing50]-_b[future50]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(50 km cutoff) keep(ongoing50 future50) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing50-future50=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 

*75 km cutoff, diff almost sign on ten now with restricted sample 
reg ethnicidentity ongoing75 future75 age age2 female urban cd* yd* if completed75==0 & restrictedestsample==1, cluster(cluster)
	test ongoing75-future75=0	
	estadd scalar difference = _b[ongoing75]-_b[future75]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(75 km cutoff) keep(ongoing75 future75) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing75-future75=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 
	




	
		


*******************Table A4: Chinese aid and ethnic identity: Sensitivity analysis
***********************************************************************************

*logit
logit ethnicidentity ongoing25 future25 age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	margins,  dydx(ongoing25 future25) post
	outreg2 using C:/Data/TEST.doc, replace dec(3) ctitle(Logit) keep(ongoing25 future25) title(Chinese aid and ethnic identity)	
	/*Add by hand:
	test ongoing25-future25=0
	estadd scalar difference = _b[ongoing25]-_b[future25]
	*/	
	
*using ordinal dependent	
reg ethid_ordinal ongoing25 future25 age age2 female urban		cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	test ongoing25-future25=0		
	estadd scalar difference = _b[ongoing25]-_b[future25]		
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Ordinal dependent) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	
	*gen ordinal_sample=1 if e(sample)==1
	*sum ethid_ordinal if ordinal_sample==1		//mean and std 
	
	
*including those with, but controlling for, completed projects nearby 
reg ethnicidentity ongoing25 future25 completed25  			age age2 female urban cd* yd* if restrictedestsample==1, cl(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]		
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Including completed) keep(ongoing25 future25 ) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	
	*test completed50-future50=0		
	*test ongoing50-completed50=0		

*alternative estimation sample (including some countries without obs connected to future)
reg ethnicidentity ongoing25 future25 age age2 female urban cd* yd* if completed25==0 & ethnicestsample2==1, cluster(cluster)
	test ongoing25-future25=0		
	estadd scalar difference = _b[ongoing25]-_b[future25]		//diff sign
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Extended sample) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 
	
	
*using only precision code 1 in the afrobarometer OPEN NEW DATASET.
preserve
	use "$aiddata/chinese all projects_afro restricted to precision code 1 data_replication.dta", clear
	rename active25 		ongoing25
	rename inactive25 		future25
	rename suspended25 		completed25
	gen 	restrictedestsample	=cond(((country=="Benin" | country=="Botswana" | country=="Cape Verde" | country=="Kenya" | country=="Liberia" | country=="Madagascar" | country=="Malawi" | country=="Mali" |	country=="Namibia" | country=="Nigeria" | country=="Senegal")  					///
 & ethnicidentity!=.	 & presethnic!=. & ongoing25!=. & future25!=. & age!=.),1,0) 	
reg ethnicidentity ongoing25 future25 age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	test ongoing25-future25=0		
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Precision code 1) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	
restore	
	
*focusing on only ODA-like flows OPEN NEW DATASET
preserve
	use "$aiddata/chinese ODA_afro precision code 1 2 3 data_replication.dta", clear
	rename active25 		ongoing25
	rename inactive25 		future25
	rename suspended25 		completed25
	gen 	restrictedestsample	=cond(((country=="Benin" | country=="Botswana" | country=="Cape Verde" | country=="Kenya" | country=="Liberia" | country=="Madagascar" | country=="Malawi" | country=="Mali" |	country=="Namibia" | country=="Nigeria" | country=="Senegal")  					///
 & ethnicidentity!=.	 & presethnic!=. & ongoing25!=. & future25!=. & age!=.),1,0) 	
reg ethnicidentity ongoing25 future25 age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	test ongoing25-future25=0		
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(only ODA) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	
restore	

*region fixed effects
reg ethnicidentity ongoing25 future25 age age2 female urban rd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Region FEs) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	
	
*geomatching. exlude those with no projects within 100 km 
reg ethnicidentity ongoing25 future25 	age age2 female urban cd* yd* if numberwithin100>0 & completed25==0 & restrictedestsample==1, cl(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Geo-matched) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	
*dropping round 6 since no obs connected to future sites 
reg ethnicidentity ongoing25 future25 age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1 & wave<6, cluster(cluster)
	test ongoing25-future25=0		
	estadd scalar difference = _b[ongoing25]-_b[future25]		
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(without wave 6) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 

*excluding observations where the future project will start during the next year 
reg ethnicidentity ongoing25 future25  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1 & timeuntilstart!=1, cluster(cluster)
	test ongoing25-future25=0		
	estadd scalar difference = _b[ongoing25]-_b[future25]		
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Exclude next year future) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	
	
* restriction on future
*focusing on future projects starting within 5 years of the interview date	
reg ethnicidentity ongoing25 future25within5  age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	test ongoing25-future25within5=0		
	estadd scalar difference = _b[ongoing25]-_b[future25within5]			
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(within 5 years) keep(ongoing25 future25within5) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 

*restricting the sample to survey rounds within the same presidency/party (ignore changes in presidency of they are within the same party) in each country
reg ethnicidentity ongoing25 future25 age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1 & noturnover==1, cluster(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(No turnover) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 
	
*country*linear timetrend.
reg ethnicidentity ongoing25 future25 age age2 female urban cd*##c.timetrend if completed25==0 & restrictedestsample==1, cluster(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Country timetrend) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	

*country-year dummies 
reg ethnicidentity ongoing25 future25 age age2 female urban cd*##yd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Country-year FEs) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	

*regionFEs * linear timetrend	
preserve
keep if restrictedestsample==1 & completed25==0
tab region, gen (rdrestricted)
set emptycells drop				//otherwise exceed maxvar 
reg ethnicidentity ongoing25 future25 age age2 female urban rdrestricted*##c.timetrend if completed25==0 & restrictedestsample==1, cluster(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	estimates store regiontimetrend
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Region timetrend) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	
restore		

/*
*wave*rd fixed effects......takes a lot of time... 
preserve
keep if restrictedestsample==1 & completed25==0
tab region, gen (rdrestricted)
set emptycells drop				//otherwise exceed maxvar 
reg ethnicidentity ongoing25 future25 age age2 female urban rdrestricted*##wd* if completed25==0 & restrictedestsample==1, cluster(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	estimates store regionwaveFE
	estimates save regionwaveFE
	outreg2 using C:/Data/TEST.doc, replace dec(3) ctitle(Region-year FEs) keep(ongoing25 future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	
restore
*/
	
	
	
	

*******Table A5: Chinese project localization: in- and out-group variation in proximity to project sites? 
*********************************************************************************************************
reg ongoing25 presethnic  age age2 female urban cd* yd* if restrictedestsample==1, cl(cluster)				
	outreg2 using C:/Data/TEST.doc, replace dec(3) ctitle(Ongoing project) keep(presethnic) title(Chinese project localization) nocons 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 
reg future25 presethnic  age age2 female urban cd* yd* if restrictedestsample==1, cl(cluster)				
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(future project) keep(presethnic) title(Chinese project localization) nocons 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 
reg numberwithin25 presethnic age age2 female urban cd* yd* if  restrictedestsample==1, cl(cluster)			
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Number of projects) keep(presethnic) title(Chinese project localization) nocons  	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 
reg _1projectdist presethnic age age2 female urban cd* yd* if restrictedestsample==1, cl(cluster)			
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Distance to nearest projects) keep(presethnic) title(Chinese project localization) nocons 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 



	
	
	
**********Table A6: Chinese aid and ethnic identity: variation across in- and out-group 
***************************************************************************************

*first only include presethnic
reg ethnicidentity ongoing25 future25 presethnic  										age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cl(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, replace dec(3) ctitle(Ethnic identity) keep(ongoing25 future25 presethnic ) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 

*country dummies
reg ethnicidentity ongoing25 future25 presethnic  preseth_ongoing25 preseth_future25	age age2 female urban cd* yd* if completed25==0 & restrictedestsample==1, cl(cluster)
	test ongoing25-future25=0												
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Ethnic identity) keep(ongoing25 future25 presethnic preseth_ongoing25 preseth_future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 
	*test (ongoing25+preseth_ongoing25)-(future25+preseth_future25)=0		
	*estadd scalar diff = _b[ongoing25]+_b[preseth_ongoing25]-_b[future25]-_b[preseth_future25]
		
*region dummies	
reg ethnicidentity ongoing25 future25 presethnic  preseth_ongoing25 preseth_future25	age age2 female urban rd* yd* if completed25==0 & restrictedestsample==1, cl(cluster)
	test ongoing25-future25=0												
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Ethnic identity) keep(ongoing25 future25 presethnic preseth_ongoing25 preseth_future25) title(Chinese aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, NO, Region FE, YES) 
	*test (ongoing25+preseth_ongoing25)-(future25+preseth_future25)=0		
	*estadd scalar diff = _b[ongoing25]+_b[preseth_ongoing25]-_b[future25]-_b[preseth_future25]

	

	
	
		
*************************************************Exploring sample balance TABLE B1
***********************************************************************************

reg age ongoing25 future25 cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster) //tend to be younger than in areas not connected to project
	test ongoing25-future25=0				//not sign diff from each other
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, replace dec(3) ctitle(Age) keep(ongoing25 future25) title(Sample balance) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Year FE, YES, Country FE, YES) 

reg female ongoing25 future25 cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster) //no major diff in gender composition
	test ongoing25-future25=0				//not sign diff from each other
	estadd scalar difference = _b[ongoing25]-_b[future25]
		outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Female) keep(ongoing25 future25) title(Sample balance) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Year FE, YES, Country FE, YES) 

reg urban ongoing25 future25 cd* yd* if completed25==0 & restrictedestsample==1, cluster(cluster) //both more urban than in areas not connected to project
	test ongoing25-future25=0				//ongoing slightly more urban. could be endogenous though. attracting companies and people
	estadd scalar difference = _b[ongoing25]-_b[future25]
		outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Urban) keep(ongoing25 future25) title(Sample balance) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Year FE, YES, Country FE, YES) 

		
	
	
	
	

	
	
	
	
	
	
	
	
	
******************************************************************WORLD BANK ESTIMATIONS*************************************************************	
*****************************************************************************************************************************************************
	
	
	

	
*OPEN THE WORLD BANK DATASET


use "$aiddata/WB all projects_afro precision code 1 2 3 data_replication.dta", clear
	
	
	
	
**********************************************Table A7: World Bank aid and ethnic identity
*******************************************************************************************	
	
*BENCHMARK REGRESSION 25 KM CUTOFF: 
reg ethnicidentity ongoing25 future25 age age2 female urban cd* yd* if completed25==0 & WBethnicestsample==1, cluster(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, replace dec(3) ctitle(Ethnic identity) keep(ongoing25 future25) title(WB aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES, Region FE, NO) 

*region dummies
reg ethnicidentity ongoing25 future25 age age2 female urban rd* yd* if completed25==0 & WBethnicestsample==1, cluster(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Ethnic identity) keep(ongoing25 future25) title(WB aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, NO, Region FE, YES) 
	
*adding presethnic
reg ethnicidentity ongoing25 future25 presethnic  										age age2 female urban cd* yd* if completed25==0 & WBethnicestsample==1, cl(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Ethnic identity) keep(ongoing25 future25 presethnic ) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES, Region FE, NO) 
	
*presethnic interactions with ongoing and future	
reg ethnicidentity ongoing25 future25 presethnic  preseth_ongoing25 preseth_future25	age age2 female urban cd* yd* if completed25==0 & WBethnicestsample==1, cl(cluster)
	test ongoing25-future25=0												
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Ethnic identity) keep(ongoing25 future25 presethnic preseth_ongoing25 preseth_future25) title(WB aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES, Region FE, NO) 
	*test (ongoing25+preseth_ongoing25)-(future25+preseth_future25)=0		//add by hand in table so as not to mess up stored values in outreg
	*estadd scalar diff = _b[ongoing25]+_b[preseth_ongoing25]-_b[future25]-_b[preseth_future25]

*presethnic interactions with ongoing and future	
reg ethnicidentity ongoing25 future25 presethnic  preseth_ongoing25 preseth_future25	age age2 female urban rd* yd* if completed25==0 & WBethnicestsample==1, cl(cluster)
	test ongoing25-future25=0												
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Ethnic identity) keep(ongoing25 future25 presethnic preseth_ongoing25 preseth_future25) title(WB aid and ethnic identity) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, NO, Region FE, YES) 
	test (ongoing25+preseth_ongoing25)-(future25+preseth_future25)=0		//
	estadd scalar diff = _b[ongoing25]+_b[preseth_ongoing25]-_b[future25]-_b[preseth_future25]
		
		
		
		
		
		
		
*************Figure A4: World Bank aid and ethnic identity: different geographical cut-offs	
*******************************************************************************************

*10 km cutoff....  diff pos but not quite sign
	gen helpvar10 = diffhelp10						
	label var helpvar10 "10 km cut-off"
reg ethnicidentity sum_ongoingfuture10 helpvar10 age age2 female urban cd* yd* if completed10==0 & WBethnicestsample==1, cluster(cluster)
	estimates store ten
	
*25 km 
	gen helpvar25 = diffhelp25						
	label var helpvar25 "25 km cut-off"
reg ethnicidentity sum_ongoingfuture25 helpvar25 age age2 female urban cd* yd* if completed25==0 & WBethnicestsample==1, cluster(cluster) 
	estimates store twentyfive
	
*50 km cutoff
	gen helpvar50= diffhelp50						
	label var helpvar50 "50 km cut-off"
reg ethnicidentity sum_ongoingfuture50 helpvar50 age age2 female urban cd* yd* if completed50==0 & WBethnicestsample==1, cluster(cluster)
	estimates store fifty
	
*75 km cutoff
	gen helpvar75 = diffhelp75						
	label var helpvar75 "75 km cut-off"
reg ethnicidentity sum_ongoingfuture75 helpvar75 age age2 female urban cd* yd* if completed75==0 & WBethnicestsample==1, cluster(cluster)
	estimates store seventyfive
		
		
coefplot  (ten) (twentyfive) (fifty) (seventyfive), nooffsets keep(helpvar*) xline(0)  xtitle(Difference b_ongoing-b_future)  graphregion(fcolor(white))  

		
		
		
		
		

************************Figure A5: World Bank aid and ethnic identity: sensitivity analysis		
*******************************************************************************************


*benchmark	
gen benchmarkvar = diffhelp25						
label var benchmarkvar "Benchmark sample"
reg ethnicidentity sum_ongoingfuture25 benchmarkvar age age2 female urban cd* yd* if completed25==0 & WBethnicestsample==1, cluster(cluster) 
	estimates store benchmarksample

*including those with, but controlling for, completed projects nearby
gen completedvar = diffhelp25
label var completedvar "Completed included"
reg ethnicidentity sum_ongoingfuture25 completedvar completed25  			age age2 female urban cd* yd* if WBethnicestsample==1, cl(cluster)
	estimates store completed

*extended estimation sample (including some countries without obs connected to future)
gen extendedvar = diffhelp25
label var extendedvar "Extended sample"
reg ethnicidentity sum_ongoingfuture25 extendedvar age age2 female urban cd* yd* if completed25==0 & WBextended==1, cluster(cluster)
estimates store extended_sample

*smaller estimation sample (excluding countries not part of the china sample, i.e. ghana. ,mozambique, south africa, uganda), 
gen restrictedvar = diffhelp25
label var restrictedvar "Restricted sample"
reg ethnicidentity sum_ongoingfuture25 restrictedvar age age2 female urban cd* yd* if completed25==0 & WBsmaller==1, cluster(cluster)
estimates store restricted_sample

*geomatching. exlude those with no projects within 100 km 
gen geomatchvar = diffhelp25
label var geomatchvar "Geo-matched"
reg ethnicidentity sum_ongoingfuture25 geomatchvar	age age2 female urban cd* yd* if numberwithin100>0 & completed25==0 & WBethnicestsample==1, cl(cluster)
	estimates store geomatch
	
*rural sub-sample	
gen ruralvar = diffhelp25
label var ruralvar "Rural sample"
reg ethnicidentity sum_ongoingfuture25 ruralvar  age age2 female urban cd* yd* if completed25==0 & urban==0 & WBethnicestsample==1, cluster(cluster)
estimates store rural

*urban sub-sample	
gen urbanvar = diffhelp25
label var urbanvar "Urban sample"
reg ethnicidentity sum_ongoingfuture25 urbanvar  age age2 female urban cd* yd* if completed25==0 & urban==1 & WBethnicestsample==1, cluster(cluster)
estimates store urban
	
*region fixed effects, diff sign on 5% with restricted sample 
gen regionFEvar = diffhelp25
label var regionFEvar "Region FEs"
reg ethnicidentity sum_ongoingfuture25 regionFEvar age age2 female urban rd* yd* if completed25==0 & WBethnicestsample==1, cluster(cluster)
estimates store regionFEs
	
*dropping round 6 since no obs connected to future sites here
gen noround6var = diffhelp25
label var noround6var "Without round 6"
reg ethnicidentity sum_ongoingfuture25 noround6var age age2 female urban cd* yd* if completed25==0 & WBethnicestsample==1 & wave<6, cluster(cluster)
estimates store withoutround6

		
*country*linear timetrend. 
gen ctimetrendvar = diffhelp25
label var ctimetrendvar "Country time trend"
reg ethnicidentity sum_ongoingfuture25 ctimetrendvar age age2 female urban cd*##c.timetrend if completed25==0 & WBethnicestsample==1, cluster(cluster)
estimates store countrytimetrend
		
*country-year dummies
gen countryyearFEvar = diffhelp25
label var countryyearFEvar "Country-year FEs"
reg ethnicidentity sum_ongoingfuture25 countryyearFEvar age age2 female urban cd*##yd* if completed25==0 & WBethnicestsample==1, cluster(cluster)
estimates store country_yearFEs

*regionFEs * linear timetrend	
keep if WBethnicestsample==1
tab region, gen (rdrestricted)
set emptycells drop				
gen regiontimetrendvar = diffhelp25
label var regiontimetrendvar "Region time trend"
reg ethnicidentity sum_ongoingfuture25 regiontimetrendvar age age2 female urban rdrestricted*##c.timetrend if completed25==0 & WBethnicestsample==1, cluster(cluster)
	estimates store regiontimetrend

coefplot  (benchmarksample)   (completed)   (extended_sample)  (restricted_sample)  (regionFEs) (geomatch) (rural) (urban) (withoutround6)  (countrytimetrend) (country_yearFEs) (regiontimetrend) ,  nooffsets   keep(benchmarkvar completedvar extendedvar restrictedvar regionFEvar geomatchvar ruralvar urbanvar noround6var ctimetrendvar countryyearFEvar regiontimetrendvar)  xline(0)  xtitle(Difference b_ongoing-b_future)  graphregion(fcolor(white))   
		
	
	
	
	
	
	
	
	

	
	
	
	
	
	
*************************************************************BILATERAL DONOR ESTIMATIONS*************************************************************	
*****************************************************************************************************************************************************
	
		
	
	
	
*******************OPEN THE BILATERAL DONOR DATASET***************	


use "$aiddata/bilateral to nig uga sen mal_afro precision code 1 2 3 data_replication.dta", clear


	
	

***************************************************************************************************	
********Table C1: Other bilateral aid and ethnic identities in Malawi, Nigeria, Senegal, and Uganda 

*25 KM CUTOFF: 
reg ethnicidentity ongoing25 future25 age age2 female urban cd* yd* if completed25==0 & ethnicestsample==1, cluster(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, replace dec(3) ctitle(Ethnic identity) keep(ongoing25 future25)  nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 

*adding presethnic
reg ethnicidentity ongoing25 future25 presethnic  										age age2 female urban cd* yd* if completed25==0 & ethnicestsample==1, cl(cluster)
	test ongoing25-future25=0	
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Ethnic identity) keep(ongoing25 future25 presethnic ) nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 
	
*presethnic interaction		
reg ethnicidentity ongoing25 future25 presethnic  preseth_ongoing25 	preseth_future25				age age2 female urban cd* yd* if completed25==0 & ethnicestsample==1, cl(cluster)
	test (ongoing25+preseth_ongoing25)=0
	estadd scalar difference = _b[ongoing25]-_b[future25]
	outreg2 using C:/Data/TEST.doc, append dec(3) ctitle(Ethnic identity) keep(ongoing25 future25 presethnic preseth_ongoing25 preseth_future25)  nocons adds(Difference in difference, e(difference), F test: ongoing25-future25=0, r(F), p value, `r(p)') 	addtext(Baseline controls, YES, Year FE, YES, Country FE, YES) 
	test (ongoing25+preseth_ongoing25)-(future25+preseth_future25)=0		//2020:
	estadd scalar diff = _b[ongoing25]+_b[preseth_ongoing25]-_b[future25]-_b[preseth_future25]

	
	
	
	
	
	

	
	
	
	
	
	
	
	
	
	
	

	
***********THE END**********
	
	
	
	
	
